import api from '@/api'
import Notification from '@/componentsEl/notification/index.js'

const state = {
  dataList: {
    records: [],
    totalPage: 0
  },
  productList: {
    records: [],
    totalPage: 0
  },
  commodityOptions: []
};
const mutations = {
  setData(state, payload) {
    state.dataList = payload
  },
  setProductData(state, payload) {
    state.productList = payload
  },
  setCommodityOptions(state, payload) {
    state.commodityOptions = payload
  }
};
const actions = {
  async get_order_model_by_status({
    commit
  }, obj) {
    const result = await api.transaction.get_order_model_by_status(obj);
    if (result.code === 200) {
      commit('setData', result.data);
    }
    return result
  },
  async get_product_model_by_status({
    commit
  }, obj) {
    const result = await api.transaction.get_product_model_by_status(obj);
    if (result.code === 200) {
      commit('setProductData', result.data);
    }
    return result
  },
  async find_product({
    commit
  }, obj) {
    const result = await api.transaction.find_product(obj);
    if (result.code === 200) {
      commit('setCommodityOptions', result.data);
    }
    return result
  },
  async apply_back_order_audit({
    commit
  }, obj) {
    const result = await api.transaction.apply_back_order_audit(obj);
    // if (result.code !== 200 && result.code !== 5223) {
    //   Notification.error(result.message)
    // }
    return result
  },
  async apply_case_audit({
    commit
  }, obj) {
    const result = await api.transaction.apply_case_audit(obj);
    // if (result.code !== 200 && result.code !== 5223) {
    //   Notification.error(result.message)
    // }
    return result
  },
  async get_order_business({
    commit
  }, obj) {
    const result = await api.transaction.get_order_business(obj);
    // if (result.code !== 200 && result.code !== 5223) {
    //   Notification.error(result.message)
    // }
    return result
  },
  async edit_bottom_sheet({ commit }, obj) {
    const result = await api.transaction.edit_bottom_sheet(obj);
    // if (result.code !== 200 && result.code !== 5223) {
    //   Notification.error(result.message)
    // }
    return result
  },
  async get_assist_handle({
    commit
  }, obj) {
    const result = await api.transaction.get_assist_handle(obj);
    // if (result.code !== 200 && result.code !== 5223) {
    //   Notification.error(result.message)
    // }
    return result;
  },
  async edit_assist_handle_main_Handle({
    commit
  }, obj) {
    const result = await api.transaction.edit_assist_handle_main_Handle(obj);
    // if (result.code !== 200 && result.code !== 5223) {
    //   Notification.error(result.message)
    // }
    return result;
  },
  async delete_assist_handle({
    commit
  }, obj) {
    const result = await api.transaction.delete_assist_handle(obj);
    // if (result.code !== 200 && result.code !== 5223) {
    //   Notification.error(result.message)
    // }
    return result
  },
  async update_project_manager({
    commit
  }, obj) {
    const result = await api.transaction.update_project_manager(obj);
    // if (result.code !== 200 && result.code !== 5223) {
    //   Notification.error(result.message)
    // }
    return result
  },
  async add_assist_handle({
    commit
  }, obj) {
    const result = await api.transaction.add_assist_handle(obj);
    // if (result.code !== 200 && result.code !== 5223) {
    //   Notification.error(result.message)
    // }
    return result
  },
  async search_files({
    commit
  }, obj) {
    const result = await api.transaction.search_files(obj);
    return result
  },
  async update_files({
    commit
  }, obj) {
    const result = await api.transaction.update_files(obj);
    return result
  },
  async delete_files({ commit }, obj) {
    const result = await api.transaction.delete_files(obj);
    return result
  },
  async search_files_cms({
    commit
  }, obj) {
    const result = await api.transaction.search_files_cms(obj);
    return result
  },
  async get_court_with_page({
    commit
  }, obj) {
    const result = await api.transaction.get_court_with_page(obj);
    return result
  },
  async undo_case_audit({ commit }, obj) {
    const result = await api.transaction.undo_case_audit(obj);
    return result
  },
  async undo_back_order_audit({ commit }, obj) {
    const result = await api.transaction.undo_back_order_audit(obj);
    return result
  }
};
const getters = {

};

export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters
}
